<%@page import="com.mvc.config.ApplicationConfig"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/pages/common/header.jsp"%>
<jdf:themeFile file="jquery.jqGrid.css"/>
<jdf:themeFile file="jqGrid/i18n/grid.locale-cn.js" />
<jdf:themeFile file="jqGrid/jquery.jqGrid.src.js" />
<jdf:themeFile file="fileuploader.css" />
<jdf:themeFile file="fileuploader.js" />
<jdf:themeFile file="fckeditor/fckeditor.js" />
<jdf:themeFile file="business/order${template}.js" />
</head>
<body>
	<div class="contentBody contentborder">
		<div class="tab-pane" id="tabPane">
			<div id="message">${message}</div>
			<div class="tab-page" id="tabPage1">
				<h1 class="tab">订单管理</h1>
				<div class="contentborder tableForm">
					<jdf:form bean="entity" scope="request">
						<form action="${dynamicDomain}/order/save?action=${param.action}" method="post" id="Order">
							<input type="hidden" name="id">
							<input type="hidden" name="objectId" id="orderId">
							<input type="hidden" name="status" id="status">
							<input type="hidden" name="financeStatus" id="financeStatus">
							<input type="hidden" name="orderDate">
							<input type="hidden" name="salesId">
							<input type="hidden" name="orderNo">
							<table class="inputTable">
								<c:if test="${not empty entity.id }">
								 <tr>
									<td class="label cancelBorderLeft">
										<label for="orderNo">订单编号：</label>
									</td>
									<td class="content" colspan="3">
										${entity.orderNo}
									</td>
								</tr>
								</c:if>
							    <tr>
									<td class="label cancelBorderLeft" style="width: 120px;">
										<label for="customerId">客户：</label>
									</td>
									<td class="content" colspan="3">
										<input type="hidden" name="customerId" id="customerId" validate="true">
										<c:choose>
									       <c:when test="${not empty entity.id && entity.status>=20}">
									           ${entity.customer.name}
									       </c:when>
									       <c:otherwise>
									       <input type="text" id="customerName" value="${entity.customer.name}" size="70" readonly="readonly"/>
									       <a href="${dynamicDomain}/customer/select?ajax=1&action=${param.action}" class="colorbox">选择客户</a>
									       </c:otherwise>
									    </c:choose>
									</td>
								</tr>
								<tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="companyId">所属公司：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="hidden" name="companyId" id="companyId" validate="true">
                                        <c:choose>
                                           <c:when test="${not empty entity.id && entity.status>=20}">
                                               ${entity.company.name}
                                           </c:when>
                                           <c:otherwise>
                                                <input type="text" id="companyName" value="${entity.company.name}" size="70" readonly="readonly"/>
                                                <a href="${dynamicDomain}/company/select?ajax=1" class="colorbox">选择公司</a>
                                           </c:otherwise>
                                        </c:choose>
                                    </td>
                                </tr>
								<tr>
								    <td class="label cancelBorderLeft">
                                        <label for="salesCondition">销售条款：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="text" name="salesCondition" size="70">
                                    </td>
								</tr>
								<tr>
                                    <td class="label cancelBorderLeft">
										<label for="shipment">船运条款：</label>
									</td>
									<td class="content" colspan="3">
										<input type="text" name="shipment" size="70">
									</td>
								</tr>
								<tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="payment">付款方式：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="text" name="payment" size="70">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="currency">币种：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <select name="currency">
                                            <option value=""></option>
                                            <jdf:select dictionaryId="1006"/>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                     <td class="label cancelBorderLeft">
                                        <label for="etdDate">ETD date：</label>
                                    </td>
                                    <td class="content">
                                       <input type="text" size="12" name="etdDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,onpicked:function(dp){setPredictPayDate($dp.$('predictPayDate'), 90);}})">
                                    </td>
                                     <td class="label">
                                        <label for="predictPayDate">付款日期：</label>
                                    </td>
                                    <td class="content">
                                       <input type="text" size="12" id="predictPayDate" name="predictPayDate" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="label cancelBorderLeft">
                                        <label for="clientPo">客人订单编号：</label>
                                    </td>
                                    <td class="content" colspan="3">
                                        <input type="text" name="clientPo" size="40">
                                    </td>
                                </tr>
								<tr>
									<td class="label cancelBorderLeft">
										<label for="remark">备注：</label>
									</td>
									<td class="content" colspan="3">
										<textarea rows="5" cols="55" name="remark" id="remark"></textarea>
										<script type="text/javascript">
                                            var txt = new FCKeditor("remark");
                                            txt.BasePath = "<%=DomainUtils.getStaticDomain()%>js/fckeditor/";
                                            txt.Config["CustomConfigurationsPath"]="<%=DomainUtils.getStaticDomain()%>js/fckeditor/myconfig.js";
                
                                            txt.ToolbarSet="Simple";
                                            txt.Height= 300;
                                            txt.Width = "98%";
                                            txt.ReplaceTextarea();
                                        </script>
									</td>
								</tr>
							</table>
						</form>
					</jdf:form>
					<div style="margin: 1px;">
						<table id="orderItemsTable"></table>
						<div id="pager"></div>
						<table id="orderChargesTable"></table>
                        <div id="pager2"></div>
					</div>
					<div class="right" style="margin: 2px;width: 100%;">
					   <div id="filelimit-fine-uploader">
                       </div>
                       <c:forEach varStatus="num" var="item" items="${entity.pictures}">
                           <div id="d_f_${item.fileId}" style="float: left;width: 200px;">
                               <a href="${dynamicDomain}/download/${item.fileId}${item.fileSuffix}" class="picture" title="${item.fileName}">
                                   <img alt="${item.fileName}" alt="${item.fileName}" src="${dynamicDomain}/download/${item.fileId}${item.fileSuffix}" width="150">
                               </a>
                               <a href="javascript:deletePicture('${item.fileId}')" style="vertical-align: top;">删除</a>
                           </div>
                       </c:forEach>
					</div>
					<div class="right" style="margin: 2px;">
						<c:if test="${view!=1 && (empty entity.status || entity.status == 1)}">
							<button type="button" onclick="$('#status').val(1);$('#Order').submit();" class="submit_button">保存草稿</button>
						</c:if>
						<c:if test="${(view!=1 && (entity.status <20))||param.action=='page'}">
							<button type="button" onclick="$('#status').val(10);$('#Order').submit();" class="submit_button">提交</button>
						</c:if>
						<c:if test="${not empty message}">
						<button type="button" onclick="toUrl('${dynamicDomain}/order/create?action=${param.action}')">继续增加</button>
						</c:if>
						<c:choose>
							<c:when test="${param.action=='page'}">
								<button type="button" onclick="toUrl('${dynamicDomain}/order/back')">返回</button>
							</c:when>
							<c:otherwise>
								<button type="button" onclick="toUrl('${dynamicDomain}/order/${param.action}')">返回</button>
							</c:otherwise>
						</c:choose>
					</div>
				</div>
			</div>
		</div>
	</div>
	<jdf:tableLabelValidate domain="Order"/>
	<script type="text/javascript">
	   var orderId = "${entity.objectId}";
	   <c:choose>
       <c:when test="${(entity.status>=20||view==1)&&param.action!='page'}">
       var orderEditable = false;
       </c:when>
       <c:otherwise>
       var orderEditable = true;
       </c:otherwise>
       </c:choose>
       orderfileCount = ${fn:length(entity.pictures)};
       
       var units = "";
       <c:forEach varStatus="num" var="item" items="${units}">
       units+="${item.value}:${item.name};";
       </c:forEach>
       units=units.substring(0,units.length-1);
       
       function cumstomerFormValidate(){
    	   var EditorInstance = FCKeditorAPI.GetInstance('remark'); 
    	   var content = $("#remark");
    	   if(EditorInstance.EditorDocument.body.innerText.length>=2048) {
    		   f_v_r +='备注内容太长!\n';
               content.addClass("onError");
    	   }else{
    		   content.addClass("onSuccess");
    	   }
       }
       
       window.onload = createUploader; 
	</script>
</body>
</html>